"use strict";

const util = require("node:util");

class Foo {
  /**
   * @param {(a: Error | null, b: number)=>void} callback
   */
  bar(callback) {
    callback(null, this.a);
  }

  a = 42;
}

const foo = new Foo();

const barPromise = util.promisify(foo.bar);
// TypeError: Cannot read property 'a' of undefined
// naiveBar().then(a => console.log(a));

barPromise.call(foo).then((a) => console.log(a)); // '42'

const bindBar = barPromise.bind(foo);
bindBar().then((a) => console.log(a)); // '42'
